home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / prim / help-nomule.el.z / help-nomule.el
Encoding:
Text File  |  1998-05-21  |  3.3 KB  |  100 lines

  1. ;;; help-nomule.el --- Help functions when not in Mule
  2.  
  3. ;; Copyright (C) 1997 by Free Software Foundation, Inc.
  4.  
  5. ;; Maintainer: XEmacs Development Team
  6. ;; Keywords: help, internal
  7.  
  8. ;; This file is part of XEmacs.
  9.  
  10. ;; XEmacs is free software; you can redistribute it and/or modify it
  11. ;; under the terms of the GNU General Public License as published by
  12. ;; the Free Software Foundation; either version 2, or (at your option)
  13. ;; any later version.
  14.  
  15. ;; XEmacs is distributed in the hope that it will be useful, but
  16. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  18. ;; General Public License for more details.
  19.  
  20. ;; You should have received a copy of the GNU General Public License
  21. ;; along with XEmacs; see the file COPYING.  If not, write to the Free
  22. ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  23. ;; 02111-1307, USA.
  24.  
  25. ;;; Synched up with: Not in FSF
  26.  
  27. ;;; Commentary:
  28.  
  29. ;; 
  30.  
  31. ;;; Code:
  32.  
  33. (defconst tutorial-supported-languages
  34.   '(("French" fr iso-8859-1)
  35.     ("German" de iso-8859-1)
  36.     ("Norwegian" no iso-8859-1)
  37.     ("Croatian" hr iso-8859-2)
  38.     ("Polish" pl iso-8859-2))
  39.   "Alist of supported languages in TUTORIAL files.
  40. Add languages here, as more are translated.")
  41.  
  42. ;; TUTORIAL arg is XEmacs addition
  43. (defun help-with-tutorial (&optional tutorial language)
  44.   "Select the XEmacs learn-by-doing tutorial.
  45. Optional arg TUTORIAL specifies the tutorial file; default is \"TUTORIAL\".
  46. With a prefix argument, choose the language."
  47.   (interactive "i\nP")
  48.   (or tutorial
  49.       (setq tutorial "TUTORIAL"))
  50.   (when (and language (consp language))
  51.     (let ((completion-ignore-case t))
  52.       (setq language (assoc (completing-read "Language: "
  53.                          tutorial-supported-languages
  54.                          nil t)
  55.                 tutorial-supported-languages))))
  56.   (when language
  57.     (setq tutorial (format "%s.%s" tutorial (cadr language))))
  58.   (let ((file (expand-file-name tutorial "~")))
  59.     (delete-other-windows)
  60.     (let ((buffer (or (get-file-buffer file)
  61.               (create-file-buffer file)))
  62.       (window-configuration (current-window-configuration)))
  63.       (condition-case error-data
  64.       (progn
  65.         (switch-to-buffer buffer)
  66.         (setq buffer-file-name file)
  67.         (setq default-directory (expand-file-name "~/"))
  68.         (setq buffer-auto-save-file-name nil)
  69.         ;; Because of non-Mule users, TUTORIALs are not coded
  70.         ;; independently, so we must guess the coding according to
  71.         ;; the language.
  72.         (let ((coding-system-for-read (nth 2 language)))
  73.           (insert-file-contents (locate-data-file tutorial)))
  74.         (goto-char (point-min))
  75.         (search-forward "\n<<")
  76.         (delete-region (point-at-bol) (point-at-eol))
  77.         (let ((n (- (window-height (selected-window))
  78.             (count-lines (point-min) (point))
  79.             6)))
  80.           (if (< n 12)
  81.           (newline n)
  82.         ;; Some people get confused by the large gap.
  83.         (newline (/ n 2))
  84.         (insert "[Middle of page left blank for didactic purposes.  "
  85.             "Text continues below]")
  86.         (newline (- n (/ n 2)))))
  87.         (goto-char (point-min))
  88.         (set-buffer-modified-p nil))
  89.     ;; TUTORIAL was not found: kill the buffer and restore the
  90.     ;; window configuration.
  91.     (file-error (kill-buffer buffer)
  92.             (set-window-configuration window-configuration)
  93.             ;; Now, signal the error
  94.             (signal (car error-data) (cdr error-data)))))))
  95.  
  96.  
  97. (provide 'help-nomule)
  98.  
  99. ;;; help-nomule.el ends here
  100.